package 如何初始化数组;
 
 
public class 数组反转11 {
    public static void main(String[] args) {
        int arr[] = getNumArr(5);
        reverse(arr);
          
    }
     
    //得到一个随机数组
    public static int[] getNumArr(int length){
        int[] arr = new int[length];
        for(int i =0;i<arr.length;++i){
            int ranNum = (int)(Math.random()*101);
            arr[i] = ranNum;
            System.out.print(ranNum+" ");
        }
        System.out.println();
        return arr;
         
    }
    //反转
    public static int[] reverse(int []arr){
        int start = 0;
        int end = arr.length-1;
        int temp = 0;
        while(start<end){
            temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
            start++;
            end --;
     
        }
        for( int i=0;i<arr.length;++i){
            System.out.print(arr[i]+" ");
        }
        return arr;
         
    }
}